<script setup lang="ts">
import { getWarnDetailAPI } from '@/apis/rodWarn';
import type { WarnItemDetailType } from '@/types/rodWarn';
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { handleStatusMap } from '@/utils/rodWarn'

const route = useRoute()

// 获取告警详情数据
const detail = ref<WarnItemDetailType>({} as WarnItemDetailType)

const getDetail = async () => {
    if (!route.params.id) return
    const res = await getWarnDetailAPI(+route.params.id)
    detail.value = res.data
}
getDetail()

</script>

<template>
    <div class="add-card">
      <header class="add-header">
        <el-page-header content="告警详情" @back="$router.back()" />
      </header>
      <main class="add-main">
        <div class="form-container">
          <div class="title">告警详情</div>
          <div class="carContent">
              <div class="tr">
                  <div class="item">
                      <span class="label">告警时间：</span>
                      <span class="value">{{ detail.warningTime }}</span>
                  </div>
                  <div class="item">
                      <span class="label">告警区域：</span>
                      <span class="value">{{ detail.areaName }}</span>
                  </div>
                  <div class="item">
                      <span class="label">故障类型：</span>
                      <span class="value">{{ detail.errorType }}</span>
                  </div>
              </div>
              <div class="tr">
                  <div class="item">
                      <span class="label">一体杆名称：</span>
                      <span class="value">{{ detail.poleName }}</span>
                  </div>
                  <div class="item">
                      <span class="label">一体杆编号：</span>
                      <span class="value">{{ detail.poleNumber }}</span>
                  </div>
                  <div class="item">
                      <span class="label">处置状态：</span>
                      <span class="value">{{ handleStatusMap.get(+detail.handleStatus) }}</span>
                  </div>
              </div>
          </div>
        </div>
        <div class="form-container">
          <div class="title">告警详情</div>
          <div class="carContent">
              <div class="tr">
                  <div class="item">
                      <span class="label">处理人：</span>
                      <span class="value">{{ detail.handleUser }}</span>
                  </div>
                  <div class="item">
                      <span class="label">处理结果：</span>
                      <span class="value">{{ detail.handleResult }}</span>
                  </div>
              </div>
              <div class="tr">
                  <div class="item">
                      <span class="label">联系方式：</span>
                      <span class="value">{{ detail.phonenumber }}</span>
                  </div>
                  <div class="item">
                      <span class="label">完成时间：</span>
                      <span class="value">{{ detail.handleTime }}</span>
                  </div>
              </div>
          </div>
        </div>
      </main>
    </div>
</template>

<style scoped lang="scss">
.carContent {
    padding: 30px 0px 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .tr {
        width: 60%;
        display: flex;
        justify-content: space-between;
        flex-direction: column;
        margin-left: 180px;
        margin-bottom: 30px;
        .item {
            &:nth-child(2) {
                margin: 25px 0;
            }
        }
        .label {
            color: #999ca2;
            font-size: 14px;
        }
        .value {
            color: #393939;
            font-weight: 500;
            font-size: 15px;
        }
    }
}

.add-card {
background-color: #f4f6f8;
height: 100vh;

.add-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;

    .left {
    span {
        margin-right: 4px;
    }

    .arrow {
        cursor: pointer;
    }
    }

    .right {
    text-align: right;
    }
}

.add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
    background-color: #fff;
    margin-bottom: 30px;
    border-radius: 10px;

    .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
        border-bottom: 1px solid #ebeef5;
    }

    .form {
        margin-bottom: 20px;
        padding: 20px 65px 24px;

        .el-form {
        display: flex;
        flex-wrap: wrap;

        .el-form-item {
            width: 50%;
        }
        }
    }
    }

    .preview {
    img {
        width: 100px;
    }
    }
}

.add-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    padding: 24px 50px;
    color: #000000d9;
    font-size: 14px;
    background: #fff;
    text-align: center;
}
}
</style>